import socket

# 创建一个UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# 绑定到本地地址和端口
server_address = ('localhost', 10000)
sock.bind(server_address)

# 循环以接收消息
while True:
    print('等待消息...')
    data, client_address = sock.recvfrom(1024)
    print('收到消息: {}'.format(data))